<?php

if (!defined('BASEPATH'))
exit('No direct script access allowed');

class Contactus extends MX_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 * 	- or -
	 * 		http://example.com/index.php/welcome/index
	 * 	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function Contactus() {
		parent::__construct();
		$this->load->model('lookupmodel');
		$this->load->model('helpermodel');
		//check is logged in
		$this->load->model('languagemodel');
		$this->language = $this->languagemodel->is_language_using();
	}

	public function index() {
		$this->lang->load('aboutus/aboutus', $this->language);

		//SEO
		$data['title'] = $this->lang->line('about_us_text_title');
		$data['description'] = $this->lang->line('about_us_text_description');
		$data['keywords'] = $this->lang->line('about_us_text_keywords');

		$data['text_heading'] = $this->lang->line('text_heading');

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text'      => '',
			'href'      => base_url()
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_heading'),
			'href'      => base_url() . 'contact-us.html'
		);
		
		$results = $this->lookupmodel->getLocationOffice($this->config->item('market'));
		$data['office'] = array();
		if($results) {
			foreach ($results as $result) {
				$data['office'][] = array(
					'name'		=> $result->Name,
					'lat'		=> $result->Latitude,
					'long'		=> $result->Longtitude,
					'content'	=> $result->Content
				);	
			} 
		}
 
		$data['module'] = "contactus";
		$data['view_file'] = "contactus";

		$data['success'] = "";

		$data['countries'] = $this->lookupmodel->getCountries($this->config->item('config_language_id'));

		echo Modules::run('template/default_template', $data);
	}

	function success() {
		$this->lang->load('aboutus/email', $this->language);

		//SEO
		$data['title'] = $this->lang->line('text_title');
		$data['description'] = $this->lang->line('text_description');
		$data['keywords'] = $this->lang->line('text_keywords');

		//Text
		$data['text_heading'] = $this->lang->line('heading_title');

		$data['module'] = "contactus";
		$data['view_file'] = "contactus";

		$data['breadcrumbs'][] = array(
			'text'      => 'Home',
			'href'      => base_url()
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_contact'),
			'href'      => base_url() . 'contact-us.html'
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('heading_title'),
			'href'      => base_url() . 'contact-us/success'
		);
		
		$results = $this->lookupmodel->getLocationOffice($this->config->item('market'));
		$data['office'] = array();
		if($results) {
			foreach ($results as $result) {
				$data['office'][] = array(
					'name'		=> $result->Name,
					'lat'		=> $result->Latitude,
					'long'		=> $result->Longtitude,
					'content'	=> $result->Content
				);	
			}
		}

		$data['success'] = $this->uri->segment(2);

		echo Modules::run('template/default_template', $data);
	}
	
	function location() {
		$this->lang->load('aboutus/aboutus', $this->language);

		//SEO
		$data['title'] = $this->lang->line('about_us_text_title');
		$data['description'] = $this->lang->line('about_us_text_description');
		$data['keywords'] = $this->lang->line('about_us_text_keywords');

		//Text
		$data['text_heading'] = $this->lang->line('heading_title');

		$data['module'] = "contactus";
		$data['view_file'] = "contactus";

		$data['breadcrumbs'][] = array(
			'text'      => 'Home',
			'href'      => base_url()
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_heading'),
			'href'      => base_url() . 'contact-us.html'
		);
		
		$data['success'] = "";
		
		$city = $this->uri->segment(3);
		$data['city'] = $city; 
		
		$results = $this->lookupmodel->getLocationOffice($this->config->item('market'));
		$data['office'] = array();
		if($results) {
			foreach ($results as $result) {
				$data['office'][] = array(
					'name'		=> $result->Name,
					'lat'		=> $result->Latitude,
					'long'		=> $result->Longtitude,
					'content'	=> $result->Content
				);	
			} 
		}

		echo Modules::run('template/default_template', $data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */